<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .button{
            width: 60px;
            height: 26px;
            background-color: #ddd;
            border-radius: 20px;
            padding: 3px;
        }

        .button::before{
            content: "";
            display: block;
            width: 26px;
            height: 26px;
            border-radius: 50%;
            background-color: #fff;
            transition: margin-left 0.5s;
        }

        input:checked ~ .button{
            background-color: skyblue;
        }

        input:checked ~ .button::before{
            margin-left: 34px;
        }
        input{
            display: none;
        }
    </style>
</head>
<body>
    <label for="on-off">
    <input type="checkbox" id="on-off"/>
    <div class="button"></div>
    </label>
</body>
</html>